package com.lc.reader.data.repository

import com.lc.reader.data.dao.BookDao
import com.lc.reader.data.model.Book
import kotlinx.coroutines.flow.Flow

class BookRepository(
    private val bookDao: BookDao
) {
    
    fun getAllBooks(): Flow<List<Book>> = bookDao.getAllBooks()
    
    suspend fun getBookById(bookId: Long): Book? = bookDao.getBookById(bookId)
    
    suspend fun insertBook(book: Book): Long = bookDao.insertBook(book)
    
    suspend fun updateBook(book: Book) = bookDao.updateBook(book)
    
    suspend fun deleteBook(book: Book) = bookDao.deleteBook(book)
    
    suspend fun deleteBookById(bookId: Long) = bookDao.deleteBookById(bookId)
    
    suspend fun updateReadingProgress(bookId: Long, currentPage: Int, lastReadTime: Long, readingProgress: Float) {
        bookDao.updateReadingProgress(bookId, currentPage, lastReadTime, readingProgress)
    }
}
